home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 24 / Mac Magazin and MacEasy Magazine CD - Issue 24.iso / Wissenschaft & Technik / ProgressCDEF ƒ / ProgressCDEF Demo ƒ / Utilities.c < prev   
C/C++ Source or Header  |  1996-06-22  |  3KB  |  102 lines

  1. #include "Math.h"
  2.  
  3. #define NIL 0L
  4. #define Min(x, y)    ((x) < (y) ? (x) : (y))
  5.  
  6. void HandleActivateEvent( WindowPtr w, Boolean activate, EventRecord *event);
  7. pascal void SliderClickProc( ControlRef c, short part);
  8. void UpdateScores( DialogPtr d);
  9. void GetSavedValues( DialogPtr dlg);
  10. short GetPrefFile();
  11. void AdjustRectangle( Rect *rc, Rect cnstr, short defW, short defH);
  12. void SetDialogFontSize( DialogPtr d, short fontNum, short fontSize);
  13.  
  14.     Handle        ih;
  15.     Rect        ir;
  16.     short        it;
  17.  
  18.  
  19. /*******************************************************************************
  20.  
  21.     •••    GetDValue            21/3/1994 at 17:04 •••
  22.  
  23. *******************************************************************************/
  24. short GetDValue( DialogPtr thisDialog, short theItem)
  25. {
  26.     short        theCVal;
  27.  
  28.     GetDItem( thisDialog, theItem, &it, &ih, &ir);
  29.     theCVal = GetCtlValue( (ControlHandle) ih);
  30.     return (theCVal);
  31. }
  32.  
  33.  
  34. /*******************************************************************************
  35.  
  36.     •••    SetDValue            21/3/1994 at 17:40 •••
  37.  
  38. *******************************************************************************/
  39. void SetDValue( DialogPtr thisDialog, short theItem, short theCVal)
  40. {
  41.     short        theOldCVal;
  42.  
  43.     GetDItem( thisDialog, theItem, &it, &ih, &ir);
  44.     theOldCVal = GetCtlValue( (ControlHandle) ih);
  45.     if ( theCVal == theOldCVal)        return;
  46.  
  47.     SetCtlValue( (ControlHandle) ih, theCVal);
  48.     if ( it == 7)        Draw1Control( (ControlHandle) ih);
  49. }
  50.  
  51.  
  52. /*******************************************************************************
  53.  
  54.     •••    BadAlert •••
  55.  
  56. *******************************************************************************/
  57. void BadAlert( short errNumber)
  58. {
  59.     Str255        dummy;
  60.  
  61.     GetIndString( dummy, 129, errNumber);
  62.     ParamText( dummy,"\p","\p","\p");
  63.     it = StopAlert( 666, 0L);
  64.     ExitToShell();
  65. }
  66.  
  67.  
  68. /*******************************************************************************
  69.  
  70.     ••• InitScoreCard        9/7/1994 at 15:47 •••
  71.  
  72. *******************************************************************************/
  73. void InitScoreCard()
  74. {
  75.     DialogPtr    d = GetNewDialog( 129, NIL, (DialogPtr) -1);
  76.     if (!d)        BadAlert(4);
  77.  
  78.     ShowWindow(d);        SelectWindow(d);
  79. }
  80.  
  81.  
  82. /*******************************************************************************
  83.  
  84.     •••    HandleOSEvent    •••
  85.  
  86. *******************************************************************************/
  87. short HandleOSEvent( EventRecord *event)
  88. {
  89.     DialogPtr    d;
  90.     short        var;
  91.     Boolean        resume = 0;
  92.  
  93.  
  94.     InitCursor();
  95.     if (( event->message & resumeFlag) != 0)    resume = 1;
  96.     d = FrontWindow();
  97.     if (d)
  98.     {
  99.         HandleActivateEvent( d, resume, event);
  100.     }
  101.     return (!resume);
  102. }